package com.twang.stock.common;

import com.alibaba.fastjson.JSONObject;
import com.jayway.jsonpath.JsonPath;
import org.assertj.core.util.Lists;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CaiLianSeCommonUtils {

    public static String 查询财联社头条预警() throws Exception {
        String urlString = "https://api3.cls.cn/v1/roll/get_roll_list?app=cailianpress&channel=0&cuid=E0310875-2098-4699-9B59-1041A325297A&last_time=1728539097&mb=iPhone15%2C3&net=1&os=ios&ov=18.0.1&platform=iphone&province_code=3101&refresh_type=0&rn=20&sign=38fb6d814d3abeae0cad631ad55e0aff&sv=8.4.5";
        URL url = new URL(urlString);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("Referer", "https://api3.cls.cn");
        List<String> strings = Lists.newArrayList();
        try (InputStreamReader isr = new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8);
             BufferedReader br = new BufferedReader(isr)) {
            String temp;
            while ((temp = br.readLine()) != null) {
                System.out.println(temp.substring(0,1000));
                strings.add(temp);
            }
            return strings.get(0);
        }
    }
}
